﻿package com.tris.apevision.shapes
{
	import org.cove.ape.Group;
	import org.cove.ape.RectangleParticle;
	import org.papervision3d.core.math.Number2D;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.objects.primitives.Cube;
	import org.papervision3d.scenes.Scene3D;
	/**
	* ...
	* @author DefaultUser (Tools -> Custom Arguments...)
	*/
	public class AVRectoid extends RectangleParticle
	{
		private var cuboid:Cube;
		
		public function AVRectoid(paperVisionScene:Scene3D, materials:MaterialsList, x:Number=0, y:Number=0, width:Number=500, depth:Number = 500, height:Number = 500, rotation:Number=0, fixed:Boolean=false, mass:Number=1, elasticity:Number=0.3, friction:Number=0, segmentsS:int = 2, segmentsT:int = 2, segmentsH:int = 2, insideFaces:int=0, excludeFaces:int=0) 
		{			
			super(x, y, width, height, rotation, fixed, mass, elasticity, friction);
			cuboid = new Cube( materials, width, depth, height, segmentsS, segmentsT, segmentsH, insideFaces, excludeFaces);
			paperVisionScene.addChild( cuboid, "cuboid" );
		}
		
		override public function init():void
		{
			super.init();
			sprite.graphics.clear();
		}
		
		override public function paint():void
		{
			cuboid.x = px;
			cuboid.y = -py;
			cuboid.rotationZ = -angle;
		}
		
		override public function set px(n:Number):void
		{
			super.px = n;
			if (this.fixed)
				paint();
		}
		
		override public function set py(n:Number):void
		{
			super.py = n;
			if (this.fixed)
				paint();
		}
		
		override public function set width(n:Number):void
		{
			super.width = n;
			if (this.fixed)
				paint();
		}
		
		override public function set height(n:Number):void
		{
			super.height = n;
			if (this.fixed)
				paint();
		}
		
		override public function set angle(n:Number):void
		{
			super.angle = n;
			if (this.fixed)
				paint();
		}
	}
	
}